[#ftl]
[#import "common/macrolibs.ftl" as lib]
[#import "common/commonclass.ftl" as cls]
[#import "common/commondb.ftl" as db]
${r"[#ftl]"}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>${r"[#assign module]"}[#if clazz.scopeClass??][@lib.moduleName clazz=clazz.scopeClass/]/${r"${item.scope.id}"}/[/#if][@lib.moduleNames clazz=clazz/]${r"[/#assign][#assign moduleName="}"${clazz.name}"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${r"${base}"}/commonjs/flexgrid/css/flexigrid.pack.css" />

<script type="text/javascript" src="${r"${base}"}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/flexgrid/js/flexigrid.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/flexgrid/js/myflexigrid.js"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${r"${base}"}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<title>${r"${moduleName}"}列表</title>
</head>
<body>
<table class="flexme3" style="display: none"></table>
<script type="text/javascript">
var grid = $(".flexme3").flexigrid(generateFlexGridCfg({
  title:'${r"${moduleName}"}列表',
  url : '${r"${base}/${module}"}/list',
  dataType : 'json',
  singleSelect: true,
  colModel:[
    ["ID", "id", 40, true, "asc",  "left", null],
    ["Name", "name", 100, true, "",  "left", null],
    ["Description", "description", 150, false, "",  "left", null],
    [#list clazz.dynaAttributes as attr][#if !attr.carrier]
    ["${attr.name}", "${db.myFieldNames["${attr.id}"]}", 100, false, "",  "left", null],
    [/#if][/#list]
    ["Operation", "description", 120, false, "",  "left", function(data, id, rowData){
      return ['<a href="javascript:addItem('+id+')">编辑</a>',
              '<a href="javascript:removeItem('+id+')">删除</a>'
      ].join(" ");
    }]
  ],
  buttons: [
    ["添加${r"${moduleName}"}", "add", addItem],
  ]
}));
function $1(id){
  return $("#"+id).val()
}
function flexGridReload(selector){
  $(selector).flexReload();
}
function addItem(id){
  var url = '${r"${base}/${module}"}/add';
  if(id){
    url = '${r"${base}/${module}"}/edit?id='+id;
  }
  var mode = id?"编辑":"添加新";
  art.dialog.open(url, {
    title: mode+'${r"${moduleName}"}',
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    width: 450,
    height: 350
  }).lock();
}
function removeItem(id){
  art.dialog({
    content: "确定要删除该${r"${moduleName}"}【id="+id+"】？",
    title: "确认删除",
    icon: "question",
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    lock: true,
    button: [{
      name: "确定",
      callback: function(){
        $.post("${r"${base}/${module}"}/remove", {id: id}, function(text){
          var result = text;
          if(result.success){
            flexGridReload(".flexme3");
          }else{
            art.dialog({
    title: "删除失败",
    icon: "error",
    content: result.err,
    width: 400,
    height: 250,
    background: '#EEE', // 背景色
    opacity: 0.05,  // 透明度
    lock: true,
    ok: true
            });
          }
        });
      }
    }, {
      name: "取消",
      focus: true
    }]
  });
}

</script>

</body>
</html>